﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using FreeSql.DataAnnotations;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Newtonsoft.Json;

namespace Bzzb.Model
{
    [ExcelExporter(Name = "工具库")]
    [Table(Name = "tool")]
    public class Tool
    {
        [IEIgnore(IsExportIgnore = true)]
        [Column(IsIdentity = true, IsPrimary = true, Name = "id")]
        [JsonProperty("id")]
        public long Id { get; set; }

        [ExporterHeader(DisplayName = "工具编号")]
        [Column(IsIdentity = true, IsIgnore = true)]
        [JsonProperty("bianhao")]
        public string BianHao { 
            get {
                return String.Format("{0:D6}", this.Id);
            }
        }

        [ExporterHeader(DisplayName = "工具名称")]
        [Column(Name = "name")]
        [JsonProperty("name")]
        public string Name { get; set; }

        [ExporterHeader(DisplayName = "工具型号")]
        [Column(Name = "xinghao")]
        [Description("型号")]
        [JsonProperty("xinghao")]
        public string Xinghao { get; set; }

        [ExporterHeader(DisplayName = "规格")]
        [Column(Name = "guige")]
        [Description("规格")]
        [JsonProperty("guige")]
        public string Guige { get; set; }

        [IEIgnore(IsExportIgnore = true)]
        [Column(Name = "created", ServerTime = DateTimeKind.Local, CanUpdate = false, DbType = "datetime(0) NOT NULL")]
        [JsonProperty("created")]
        public DateTime Created { get; set; }

        [IEIgnore(IsExportIgnore = true)]
        [Column(Name= "updated", ServerTime = DateTimeKind.Local, DbType = "datetime(0) NOT NULL")]
        [JsonProperty("updated")]
        public DateTime Updated { get; set; }
    }
}
